<script setup>
import { ref, reactive } from "vue";
const tableData = ref([
  { name: "Jack", age: 23, email: "jack@example.com" },
  { name: "Lucy", age: 23, email: "Lucy@example.com" },
  { name: "Smith", age: 23, email: "Smith@example.com" },
  { name: "Bob", age: 23, email: "Bob@example.com" }
]);
const handleEdit = scope => {console.log(scope.row)};
function handleDelete(scope) {
  const idx = scope.$index;
  tableData.value.splice(idx, 1);
}
</script>

<template>
  <div>
    <el-table :data="tableData" stripe>
      <el-table-column fixed type="index" width="50" />
      <el-table-column fixed prop="name" label="姓名" width="150" />
      <el-table-column fixed prop="age" label="年龄" width="120" />
      <el-table-column fixed prop="email" label="邮箱" width="250" />
      <el-table-column fixed label="操作" width="350">
        <template #default="scope">
          <el-button @click="handleEdit(scope)" type="primary">编辑</el-button>
          <el-button @click="handleDelete(scope)" type="danger">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<style scoped>
.el-table {
  width: 50%;
  margin: 0 auto;
  border: 1px solid green;
}
</style>
